<?php
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system 
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : language.php   FILE_PATH : E:\www\\branches\_B2B\classes\application\language.php
 * ....多语言操作类
 *
 * @copyright workflow_system 
 * @author workflow Develop Team 
 * @package 
 * @subpackage 
 * @version Tue Jun 24 22:56:44 CST 2008
 */
defined('Base_Use_Sign') or die("this is invalid system!please contact <a href='http://www.shopnc.net'>www.shopnc.net</>.");
class LanguageClass extends FrameWork {
	/**
	 * 多语言信息列表 
	 * @author workflow Develop Team     
	 * @param  
	 * @return array
	 */
	function listLanguage($condition,&$obj_page){
		$conditionstr = $this->_conditionSearch($condition);
		$language_array = $GLOBALS['db']->GetList($conditionstr, $obj_page, "language");
		return $language_array;
	}
	
	/**
	 * 构造检索条件
	 * @author workflow Develop Team     
	 * @param  
	 * @return string
	 */
	function _conditionSearch($condition){
		$conditionstr = "";
		//是否为默认语言
		if ($condition['state'] != ''){
			$conditionstr .= " and language_state = '". $condition['state'] ."'";
		}
		//语言标识
		if ($condition['sign'] != ''){
			$conditionstr .= " and language_sign = '". $condition['sign'] ."'";
		}
		//ID不等于
		if ($condition['no_id'] != ''){
			$conditionstr .= " and language_id != '". $condition['no_id'] ."'";
		}
		
		return $conditionstr;
	}
	
	/**
	 * 新增多语言信息
	 * @author workflow Develop Team     
	 * @param  $value_array
	 * @return bool
	 */
	function addLanguage($value_array){
		if (is_array($value_array)){
			$valueArray = array();
			foreach ($value_array as $k => $v){
				if ($v != ''){
					$valueArray[$k] = $v;
				}
			}
			$insert_rs = $GLOBALS['db']->InsertRow($value_array, 'language', 'language_id');
			return $insert_rs;
		}else {
			return false;
		}
	}
	
	/**
	 * 通过ID取语言信息
	 * @author workflow Develop Team     
	 * @param  $id 信息ID
	 * @return int/bool/object/array
	 */
	function getOneLanguageById($id){
		if (intval($id) > 0) {
			return $GLOBALS['db']->GetOneRow(intval($id),'language','language_id');
		}else {
			return false;
		}
	}
	
	/**
	 * 通过path取语言信息
	 * @author workflow Develop Team     
	 * @param  $path 信息path
	 * @return int/bool/object/array
	 */
	function getOneLanguageByPath($path){
		if ($path != '') {
			return $GLOBALS['db']->GetOneRow($path,'language','language_path');
		}else {
			return false;
		}
	}
	
	/**
	 * 修改语言信息
	 * @author workflow Develop Team     
	 * @param  
	 * @return int/bool/object/array
	 */
	function updateLanguage($value_param){
		$valueArray = array();		
		foreach ($value_param as $k => $v){
			if($k !=""){
				$valueArray[$k] = $v;
			}
		}
		$update_rs = $GLOBALS['db']->UpdateRow($value_param['language_id'],$valueArray, 'language', 'language_id');
		return $update_rs;
	}
	
	/**
	 * 更改语言默认状态，只保留一个默认语言 
	 * @author workflow Develop Team     
	 * @param  $state状态 
	 * @return bool
	 */
	function updateDefaultState($state){
		$valueArray = array();
		$valueArray['language_state'] = $state;
		$result = $GLOBALS['db']->UpdateRows('language',$valueArray);
		return $result;
	}
	
	/**
	 * 删除信息 
	 * @author workflow Develop Team     
	 * @param  
	 * @return int/bool/object/array
	 */
	function delLanguage($id){
		if (intval($id) > 0){
			$result = $GLOBALS['db']->DelRow(intval($id),'language','language_id');
			return $result;
		}else {
			return false;
		}
	}
}
?>